<!doctype html>
<html>
<head>
<title>Session Stat</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<link href='css/bootstrap.min.css' rel="stylesheet" />
<link href="css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/lang.js" type="text/javascript" charset="utf8"></script>
<script src="js/common.js" type="text/javascript" charset="utf8"></script>
</head>
<body>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <h3 style="display:inline;">
                    Web Session Stat
                    <a href="websession.json" target="_blank" class="lang"  langKey="ViewJSONAPI"></a>
                    <span style="font-size:50%;font-weight:100;">
                        ${(dubboProvider.toNameString())!}
                    </span>
                </h3>
                <table id="dataTable" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>N</th>
                            <th>
                                <a id="th-SESSIONID" class="lang" langKey="SESSIONID">SESSIONID</a>
                            </th>
                            <th>
                                <a id="th-Principal" class="lang" langKey="Principal">Principal</a>
                            </th>
                            <th>
                                <a id="th-CreateTime" class="lang" langKey="CreateTime">CreateTime</a>
                            </th>
                            <th>
                                <a id="th-LastAccessTime" class="lang" langKey="LastAccessTime">LastAccessTime</a>
                            </th>
                            <th>
                                <a id="th-RemoteAddress" class="lang" langKey="RemoteAddress">RemoteAddress</a>
                            </th>
                            <th>
                                <a id="th-RequestCount" class="lang" langKey="RequestCount">RequestCount</a>
                            </th>
                            <th>
                                <a id="th-RequestTimeMillisTotal" class="lang" langKey="RequestTimeMillisTotal">RequestTimeMillisTotal</a>
                            </th>
                            <th>
                                <a id="th-RunningCount" class="lang" langKey="RunningCount">RunningCount</a>
                            </th>
                            <th>
                                <a id="th-ConcurrentMax" class="lang" langKey="ConcurrentMax">ConcurrentMax</a>
                            </th>
                            <th>
                                <a id="th-JdbcExecuteCount" class="lang" langKey="JdbcExecuteCount">JdbcExecuteCount</a>
                            </th>
                            <th>
                                <a id="th-JdbcExecuteTimeMillis" class="lang" langKey="JdbcExecuteTimeMillis">JdbcExecuteTimeMillis</a>
                            </th>
                            <th>
                                <a id="th-JdbcCommitCount" class="lang" langKey="JdbcCommitCount">JdbcCommitCount</a>
                            </th>
                            <th>
                                <a id="th-JdbcRollbackCount" class="lang" langKey="JdbcRollbackCount">JdbcRollbackCount</a>
                            </th>
                            <th>
                                <a id="th-JdbcFetchRowCount" class="lang" langKey="JdbcFetchRowCount">JdbcFetchRowCount</a>
                            </th>
                            <th>
                                <a id="th-JdbcUpdateCount" class="lang" langKey="JdbcUpdateCount">JdbcUpdateCount</a>
                            </th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
                    $.namespace("druid.websession");
                    druid.websession = function() {
                        return {
                            init : function() {
                                $("#dataTable th a").click(function(obj) {
                                    druid.common.setOrderBy(obj.target.id.substring(3))
                                })

                                druid.common.buildHead(6);
                                druid.common.ajaxuri = 'websession.json?';
                                druid.common.handleCallback = druid.websession.handleAjaxResult;
                                druid.common.ajaxRequestForBasicInfo();

                                // setInterval("druid.common.ajaxRequestForBasicInfo();", 10000);
                            },

                            handleAjaxResult : function(data) {
                                var statList = data.Content;
                                if (statList == null)
                                    return;

                                var sqlStatTable = document.getElementById("dataTable");
                                while (sqlStatTable.rows.length > 1) {
                                    sqlStatTable.deleteRow(1);
                                }

                                var html = "";
                                for (var i = 0; i < statList.length; i++) {
                                    var stat = statList[i];
                                    var newRow = sqlStatTable.insertRow(-1);
                                    html += "<tr>";

                                    if (stat.hasSessionRequest) {
                                        html += '<td title="相关的请求">' + '<a target="_blank" href="session-request?sessionId=' + stat.SESSIONID + '"><b>' + (i + 1) + "</b></a></td>";
                                    } else {
                                        html += '<td>' + (i + 1) + "</td>";
                                    }

                                    html += "<td>" + '<a target="_blank" href="websession-detail.html?sessionId=' + stat.SESSIONID + '">' + stat.SESSIONID + '</a>';
                                    if (stat.Principal) {
                                        html += "<td>" + stat.Principal + "</td>";
                                    } else {
                                        html += "<td></td>";
                                    }
                                    html += "<td>" + replace(stat.CreateTime) + "</td>";
                                    html += "<td>" + replace(stat.LastAccessTime) + "</td>";
                                    html += "<td>" + replace(stat.RemoteAddress) + "</td>";
                                    html += "<td>" + replace(stat.RequestCount) + "</td>";
                                    html += "<td>" + replace(stat.RequestTimeMillisTotal) + "</td>";
                                    html += "<td>" + replace(stat.RunningCount) + "</td>";
                                    html += "<td>" + replace(stat.ConcurrentMax) + "</td>";
                                    html += "<td>" + replace(stat.JdbcExecuteCount) + "</td>";
                                    html += "<td>" + replace(stat.JdbcExecuteTimeMillis) + "</td>";
                                    html += "<td>" + replace(stat.JdbcCommitCount) + "</td>";
                                    html += "<td>" + replace(stat.JdbcRollbackCount) + "</td>";
                                    html += "<td>" + replace(stat.JdbcFetchRowCount) + "</td>";
                                    html += "<td>" + replace(stat.JdbcUpdateCount) + "</td>";
                                    html += "</tr>";
                                }
                                $("#dataTable tbody").html(html);
                                druid.common.stripes();
                            }
                        }
                    }();
                    $(document).ready(function() {
                        druid.websession.init();
                    });
                </script>
</body>
</html>